﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Training9
{
    public partial class frmCourseUP : Form
    {
        public frmCourseUP()
        {
            InitializeComponent();
        }
        public int currindex;
        private void button1_Click(object sender, EventArgs e)
        {
            SqlOperate obj = new SqlOperate();
            string strSql = "UPDATE T_Course SET courseName ='" + textBox2.Text + "' WHERE courseID='" + textBox1.Text + "'";
            if (obj.RunSql(strSql) > 0)
            {
                MessageBox.Show("修改记录成功！", "信息提示", MessageBoxButtons.OK);
                //dataGridView1.Rows[currindex].Cells[0].Value = textBox1.Text;
                dataGridView1.Rows[currindex].Cells[1].Value = textBox2.Text;
            }
            else
            { MessageBox.Show("修改记录失败！", "信息提示", MessageBoxButtons.OK); }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            SqlOperate obj = new SqlOperate();
            string strSql = "DELETE FROM T_Course WHERE courseID='" + textBox3.Text + "'";
            if (obj.RunSql(strSql) > 0)
            {
                MessageBox.Show("删除记录成功！", "信息提示", MessageBoxButtons.OK);
                //dataGridView1.Rows.RemoveAt(currindex);
                //textBox2.Text = "";
                textBox3.Text = "";
            }
            else
            { MessageBox.Show("删除记录失败！", "信息提示", MessageBoxButtons.OK); }
        }
    }
}
